<template>
  <div>
    <el-dialog
      :title="myTitle"
      :visible.sync="show"
      :before-close="cancel"
      width="40%"
    >
      <div class="formBox">
        <div class="formHead">监测点{{ myTitle }}</div>
        <div class="formWhite">
          <div class="left">项目名称</div>
          <div class="right">
            <el-input
              v-model="itemForm.projectName"
              placeholder="请输入"
              size="small"
              :disabled="detailDis"
            ></el-input>
          </div>
        </div>
        <div class="formGray">
          <div class="left">所属白蚁防治公司</div>
          <div class="right">
            <el-select
              v-model="itemForm.controlId"
              size="small"
              placeholder="请选择"
              :disabled="detailDis"
              filterable
            >
              <el-option
                v-for="item in companyList"
                :key="item.controlId"
                :value="item.controlId"
                :label="item.controlName"
                ></el-option
              >
            </el-select>
          </div>
        </div>
        <div class="formWhite">
          <div class="left">地址</div>
          <div class="right">
            <el-input
              v-model="itemForm.detailAddress"
              placeholder="请输入"
              size="small"
              :disabled="detailDis"
            ></el-input>
          </div>
        </div>
        <div class="formGray">
          <div class="left">项目类型</div>
          <div class="right">
            <el-select
              v-model="itemForm.projectType"
              size="small"
              placeholder="请选择"
              :disabled="detailDis"
            >
              <el-option
                v-for="item in typeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </div>
        </div>
        <div class="formWhite">
          <div class="left">监测点数</div>
          <div class="right">
            <el-input
              v-model="itemForm.monitorPointNum"
              placeholder="请输入"
              size="small"
              :disabled="detailDis"
            ></el-input>
          </div>
        </div>
        <div class="formGray">
          <div class="left">运行状态</div>
          <div class="right">
            <el-select
              v-model="itemForm.runningState"
              size="small"
              placeholder="请选择"
              :disabled="detailDis"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </div>
        </div>
        <div class="formWhite">
          <div class="left">经纬度</div>
          <div class="right">
            <el-input
              v-model="itemForm.latLong"
              placeholder="请输入"
              size="small"
              :disabled="detailDis"
            ></el-input>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          @click="enSure"
          size="small"
          v-if="myTitle == '编辑'"
          >确定</el-button
        >
        <el-button type="primary" plain @click="cancel" size="small"
          >取消</el-button
        >
      </span>
    </el-dialog>
    <!-- <div class="mainName">监测点管理→监测点{{ myTitle }}</div> -->
    <!-- <div class="btnGroupLeft">
      <div class="left">
        
      </div>
    </div>-->
  </div>
</template>

<script>
import {
  addProjectData, // 新增项目
  updateProjectData, // 项目编辑
} from "@/api/manage/asset";
import { getControlCompanyData } from "@/api/manage/approval";
export default {
  props: ["myTitle", "detailDis", "id", "detailRow", "show"],
  data() {
    return {
      itemForm: {},
      options: [
        {
          label: "初始",
          value: "初始",
        },
        {
          label: "结束",
          value: "结束",
        },
      ],
      // 项目类型
      typeList: [
        {
          value: "住宅",
          label: "住宅",
        },
        {
          value: "非住宅",
          label: "非住宅",
        },
      ],
      companyList: [],
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      console.log(this.id, "00000000");
      getControlCompanyData().then((res) => {
        if (res.errorCode === "000000") {
          this.companyList = res.data;
        }
        console.log(res, "gongsi");
      });
      this.itemForm = { ...this.detailRow };
    },
    enSure() {
      console.log(this.itemForm, "itemForm");
      updateProjectData(this.itemForm).then((res) => {
        console.log(res, "22222222");
        if (res.errorCode == "000000") {
          this.$modal.msgSuccess("编辑项目成功");
          this.$emit("closeMsg", true);
        }
      });
    },
    cancel() {
      console.log(1111);
      this.$emit("closeMsg");
    },
  },
};
</script>

<style lang="scss" scoped>
// .app-main {
.formBox {
  .left {
    display: inline-block;
    height: 44px;
    line-height: 44px;
    width: 120px;
    padding-right: 15px;
    border-left: 1px solid #e4e4dc;
    border-right: 1px solid #e4e4dc;
    font-family: MicrosoftYaHei;
    font-size: 12px;
    color: #303133;
    text-align: right;
    vertical-align: top;
  }
  .right {
    display: inline-block;
    width: calc(100% - 120px);
    height: 44px;
    border-right: 1px solid #e4e4dc;
    padding: 6px 15px;
    .el-select {
      width: 100% !important;
    }
    .el-input {
      width: 100% !important;
    }
  }
  .formHead {
    width: 100%;
    height: 44px;
    background-color: #5d6d7f;
    height: 44px;
    line-height: 44px;
    text-align: center;
    font-family: MicrosoftYaHei, MicrosoftYaHei;
    font-weight: bold;
    font-size: 12px;
    color: #ffffff;
  }
  .formWhite {
    width: 100%;
    height: 44px;
    background-color: #fff;
    border-bottom: 1px solid #e4e4dc;
  }
  .formGray {
    width: 100%;
    height: 44px;
    background-color: #dbe2e6;
    border-bottom: 1px solid #e4e4dc;
  }
}
.mainName {
  font-family:
    PingFangSC,
    PingFang SC;
  font-weight: 500;
  font-size: 16px;
  height: 30px;
  line-height: 30px;
  color: #000000;
  border-bottom: 1px solid #dcdfe6;
  margin-bottom: 10px;
}
::v-deep .el-dialog__header {
  border-bottom: 1px solid #e9e9ec;
}
::v-deep .el-dialog__footer {
  border-top: 1px solid #e9e9ec;
}
// }
.el-collapse .el-collapse-item__header {
  font-size: 16px;
  font-weight: bold;
}

.pagination-container {
  margin-top: 20px;
  width: 100%;
}

.pagination-container .el-pagination {
  display: flex;
  justify-content: center;
  width: 100%;
}
</style>
